package cn.scantd.core.model;

import java.io.Serializable;

import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;

import cn.scantd.core.attrs.Scope;
import cn.scantd.core.util.EnumUtil;
import cn.scantd.kit.StrKit;

public class JavaField implements Serializable{

    private static final long serialVersionUID = -2338899965871643561L;
    
    private String name;
    private String fullName;
    private String clazz;
    private boolean isStatic;
    private boolean isFinal;
    private Scope scope;
    private JavaDoc javaDoc;
    
    public JavaField(FieldDeclaration fieldDeclaration, VariableDeclarationFragment variableDeclarationFragment) {
        name = StrKit.trim(variableDeclarationFragment.getName().getIdentifier());
        fullName = StrKit.trim(variableDeclarationFragment.getName().getFullyQualifiedName());
        clazz = StrKit.trim(fieldDeclaration.getType().toString());
        scope = EnumUtil.getScope(fieldDeclaration.getModifiers());
        isStatic = fieldDeclaration.modifiers().contains(Modifier.STATIC);
        isFinal = fieldDeclaration.modifiers().contains(Modifier.FINAL);
        javaDoc = new JavaDoc(fieldDeclaration.getJavadoc());
    }
    
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getFullName() {
        return fullName;
    }
    public void setFullName(String fullName) {
        this.fullName = fullName;
    }
    public String getClazz() {
        return clazz;
    }
    public void setClazz(String clazz) {
        this.clazz = clazz;
    }
    public boolean isStatic() {
        return isStatic;
    }
    public void setStatic(boolean isStatic) {
        this.isStatic = isStatic;
    }
    public boolean isFinal() {
        return isFinal;
    }
    public void setFinal(boolean isFinal) {
        this.isFinal = isFinal;
    }
    public Scope getScope() {
        return scope;
    }
    public void setScope(Scope scope) {
        this.scope = scope;
    }
    public JavaDoc getJavaDoc() {
        return javaDoc;
    }
    public void setJavaDoc(JavaDoc javaDoc) {
        this.javaDoc = javaDoc;
    }
    
}
